package com.jiangcheng.demo.mapper;

import com.jiangcheng.demo.entity.Comment;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jiangcheng.demo.utils.FindCommentsVo;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author admin
 * @since 2021-07-26
 */
public interface CommentMapper extends BaseMapper<Comment> {

    // 根据文章ID查询评论
    @Select("SELECT username,u_pic,c.id as c_id,content,c.created_time FROM comment as c inner join user  on user.id = c.u_id WHERE art_id = #{artId}")
    List<FindCommentsVo> findCommentsByArtId(int artId);


    // 根据树洞ID查询评论
    @Select("SELECT username,u_pic,c.id as c_id,content,c.created_time FROM comment as c inner join user  on user.id = c.u_id WHERE t_id = #{tId}")
    List<FindCommentsVo> findCommentsByTreeId(int tId);
}
